package com.ruibang.glass.material.service.impl.yqyb;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruibang.glass.material.constant.Constants;
import com.ruibang.glass.material.domain.req.ycl.ManageLocationReq;
import com.ruibang.glass.material.entity.ycl.MaterialLocationManagement;
import com.ruibang.glass.material.entity.yqyb.MaterialYBYQLocationManagement;
import com.ruibang.glass.material.mapper.ybyq.GMaterialYBYQLocationManagementMapper;
import com.ruibang.glass.material.service.yqyb.GMaterialYBYQLocationManagementService;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 原材料库位管理表 服务实现类
 * </p>
 *
 * @author mameng
 * @since 2024-04-01
 */
@Service
public class GMaterialYBYQLocationManagementServiceImpl extends ServiceImpl<GMaterialYBYQLocationManagementMapper, MaterialYBYQLocationManagement> implements GMaterialYBYQLocationManagementService {
    /**
     * 列表
     * @param   manageLocationReq
     * @return
     */
    @Override
    public IPage<MaterialYBYQLocationManagement> getPage(ManageLocationReq manageLocationReq) {
        LambdaQueryWrapper<MaterialYBYQLocationManagement> queryWrapper = Wrappers.<MaterialYBYQLocationManagement>lambdaQuery();
        if (StringUtils.isNotBlank(manageLocationReq.getLocationName())) {
            queryWrapper.like(MaterialYBYQLocationManagement::getLocationName, manageLocationReq.getLocationName());
        }
        if (StringUtils.isNotBlank(manageLocationReq.getLocationName())) {
            queryWrapper.like(MaterialYBYQLocationManagement::getLocationName, manageLocationReq.getLocationName());
        }
        if (StringUtils.isNotBlank(manageLocationReq.getStatus())) {
            queryWrapper.like(MaterialYBYQLocationManagement::getStatus, manageLocationReq.getStatus());
        }
        Page<MaterialYBYQLocationManagement> materialWarehouseInfoPage = baseMapper.selectPage(new Page<>(manageLocationReq.getPageNo(), manageLocationReq.getPageSize()),
                queryWrapper.orderByDesc(MaterialYBYQLocationManagement::getCreateTime)
        );
        return materialWarehouseInfoPage;
    }

    /**
     * 集合
     * @param
     * @return
     */
    @Override
    public List<MaterialYBYQLocationManagement> getSelectList() {
        List<MaterialYBYQLocationManagement> materialLocationManagements = baseMapper.selectList
                (Wrappers.<MaterialYBYQLocationManagement>lambdaQuery()
                        .select(MaterialYBYQLocationManagement::getId, MaterialYBYQLocationManagement::getLocationName)
                        .eq(MaterialYBYQLocationManagement::getStatus, Constants.ONE_STR)
                );
        return materialLocationManagements;
    }
}
